<?php echo $this->render('html-head.phtml');?>

  <script>
    $.metadata.setType("attr", "validate");
function update_cat_selected(){
	// alert($(this).val());
	var cat = '';
	var box = $(".cat_select:checked").each(
	    function(){
		if (cat == '')
		    cat = $(this).val();
		else
		    cat += ',' + $(this).val();
	    });
	// alert(cat);
	$("#cat_selected").val(cat);
    }
$(document).ready(function(){
    $("form").validate();
    update_cat_selected();
    $(".cat_select").click(function (){
    update_cat_selected();
    });
});
  </script>
<style>
div{border: 1px solid black;}
</style>
  <div class="div_content medium" style="text-align: left; ">

<?php 

  function print_cats($cats, $prefix)
{
  if (is_array($cats) && count($cats) > 0)
    {
      $i=1;
      print "$prefix<div>";
      foreach($cats as $cat)
	{
	  /* if(!($i++ % 1)) */
	  /* echo "<br/>"; */
	  /* print "<tr>"; */
	  //print_r($cat["detail"]);
	  foreach($cat['detail'] as $id=>$name)
	    {

	      ?>
	      <div class="left">
		<label><input type="checkbox" value="<?php echo $id;?>"/><span class="title"><?php echo $name;?></span></label>
	      </div>
		<?php
		}
		   /* print "<div class='clear'></div>"; */
	  /* print "<br/>"; */
	  if (is_array($cat["children"]) && count($cat["children"]) > 0)
	    {
	      /* print "</tr><tr><td>&nbsp;</td><td>"; */
	      print_cats($cat["children"], $prefix.$prefix);
	      /* print "<td>"; */
	    }
	  /* print "</tr>"; */
	}
      print "<div class='clear'></div>";
      print "</div>";
    }

}
print_cats($this->cats, "........");
?>
  </div>
<?php echo $this->render('user/foot.phtml');?>

